<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
    同步回调
    异步回调
    */


    // 同步回调
    /* [1, 2, 3].forEach(item => {
      console.log(item)
    })
    console.log('forEach()之后') */

    
    new Promise((resolve, reject) => { // 执行器
      console.log('excutor');
      // 执行异步请求
      axios.get()
      // 如果成功了
      resolve(value)
      // 如果失败
      reject(reason)
    })
    console.log('new Promise()之后');


    // 异步回调
    setTimeout(() => { 
      console.log('执行timout回调')
    }, 0)
    console.log('setTimeout()之后')

    Promise.resolve(1).then(() => {// 异步回调
      console.log('promise成功的回调')
    })
    
    console.log('.then之后')
  </script>

  <script>
    function fn() {
      for (let index = 0; index < 10000; index++) {
        // console.log(index)
      }
    }
    
    
    setTimeout(() => {  // setTimeout()是瞬间执行完的
      console.log('定时器的回调')
    }, 1000);
    fn() // 就会影响到定时器不准时执行
    console.log('setTimeout之后')
    
    $.get('/xxx.json', function (data) {   // get方法在将请求发出后就立即结束
      
    })
    console.log('get发请求后')
    
    /* Promise.resolve(1).then(value => {
      console.log('onResoveled', value)
    }) */

    
  </script>
</body>
</html>